// g++ -std=c++11 ranges_test.cpp


// Original version per STL ---------------------------------------------------------------------------------
template <typename It, typename T>
It find(It b, It e, T value)
{
	for (; b != e; ++b)
	{
		if (value == *b) break;
	}
	return b;
}



// Using ranges ---------------------------------------------------------------------------------

#define _ITERATOR_DEBUG_LEVEL 0		//Disable MSVC checked iterators

#include <iterator>
#include <vector>					//to hack
#include <iostream>
#include <typeinfo>					//remove

#include "container_adapter.hpp"
#include "ranges.hpp"
#include "algorithm.hpp"

//element_trait


//---------------------------------------------------------------------------------





int main( /* int argc, char* argv[] */ )
{

#ifdef _MSC_VER

	int temp[] = {1, 2, 3, 4, 5};
	std::vector<int> v (temp, temp+5);

#else

	std::vector<int> v = {1, 2, 3, 4, 5};

#endif

	int value = 3;


	//------------------------------------------------------------------
	//auto i = find(v.begin(), v.end(), value);
	//if (i != v.end())
	//{
	//	std::cout << *i;
	//}
	//------------------------------------------------------------------

	//auto r = find ( v.all(), value );
	auto r = find ( all(v), value );
	if ( ! r.empty() )
	{
		std::cout << r.front();
	}

//	//auto xxx = retro(r);
//	auto xxx = find( retro( all(v) ), value);
//	//auto xxx = retro(find(retro(r)));
//	if ( ! xxx.empty() )
//	{
//		std::cout << xxx.front();
//	}


	auto r2 = find_end ( all(v), value );
	if ( ! r2.empty() )
	{
		std::cout << r2.front();
	}





	return 0;
}
